export function setCookie(name, value, days) {
    var d = new Date();
    if (null == days) {
        days = 7;
    }
    d.setTime(d.getTime() + (days * 24 * 60 * 60 * 1000));
    var expires = "expires=" + d.toUTCString();
    document.cookie = name + "=" + value + "; " + expires;
}

export function getCookie(name) {
    var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
    if (arr = document.cookie.match(reg)) {
        return (arr[2]);
    }
    return null;
}

export function delCookie(name) {
    var days = new Date();
    days.setTime(days.getTime() - 1);
    var value = getCookie(name);
    if (null != value) {
        document.cookie = name + "=" + value + ";expires=" + days.toUTCString();
    }
}